package cn.ctodb.wxmp.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * A Mp.
 */
@Entity
@Table(name = "mp")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "mp")
public class Mp implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "token")
    private String token;

    @Column(name = "appid")
    private String appid;

    @Column(name = "appsecret")
    private String appsecret;

    @OneToOne
    @JoinColumn(unique = true)
    private Menu menu;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getToken() {
        return token;
    }

    public Mp token(String token) {
        this.token = token;
        return this;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getAppid() {
        return appid;
    }

    public Mp appid(String appid) {
        this.appid = appid;
        return this;
    }

    public void setAppid(String appid) {
        this.appid = appid;
    }

    public String getAppsecret() {
        return appsecret;
    }

    public Mp appsecret(String appsecret) {
        this.appsecret = appsecret;
        return this;
    }

    public void setAppsecret(String appsecret) {
        this.appsecret = appsecret;
    }

    public Menu getMenu() {
        return menu;
    }

    public Mp menu(Menu menu) {
        this.menu = menu;
        return this;
    }

    public void setMenu(Menu menu) {
        this.menu = menu;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Mp mp = (Mp) o;
        if (mp.id == null || id == null) {
            return false;
        }
        return Objects.equals(id, mp.id);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "Mp{" +
            "id=" + id +
            ", token='" + token + "'" +
            ", appid='" + appid + "'" +
            ", appsecret='" + appsecret + "'" +
            '}';
    }
}
